Introduction to VB CodePro
Introduction

CodePro is a programming assistant that automatically adds comment headers and error handlers to Visual Basic code, significantly reducing the time spent performing these activities.  Code added by CodePro can be completely customized, via templates, to match any company’s coding standards.

Every procedure gets individually tailored comment headers and error handlers.  CodePro recognizes and automatically replaces the following keywords:  Module Name, Procedure Name, Procedure Type, Typed and Scoped Procedure Name, Parameters, ParameterNames, Author, Date.

Code Pro has unmatched capabilities in selecting which procedures and code fragments will be annotated.  Is a project partially commented?  Did it come from another author?  Does it have non-existent or inconsistent error handling?  Simply select the procedures to be updated and let CodePro do the hard work.

Getting Started

Adding a Module Header

Adding Procedure Headers

Adding Error Handlers

Adding Headers and Error Handlers to an Entire Project

Removing Code Markers

Removing Code Added by CodePro

Removing Code Markers from an Entire Project

Removing Code Added by CodePro from an Entire Project

Closing All Windows

CodePro Options

Creating Templates

Coding Tips


License Agreement

Carefully read the following terms and conditions before using this software.  Use of this software indicates acceptance of this license agreement.

Software Versions

There are two versions of VB CodePro (registered and evaluation).  The registered version requires registration with EarthRise Software, which includes payment of the then current license fee. The evaluation version is not free software.  All rights and licenses to the shareware version automatically expire after 30 days, after which the full version must be purchased or usage of the software must stop using.  For details on ordering methods, please visit the VB CodePro homepage. Use of the evaluation version after the 30-day evaluation period is a violation of U.S. and international copyright laws.

Usage License

One copy of the evaluation version of VB CodePro may be used by a single person for evaluation purposes without charge for 30 days.  Subsequent downloads of the evaluation version by or for the same user do not extend, renew, or otherwise restart the term of the license for the evaluation version.

One copy of the registered version of VB CodePro may either be used by a single person who uses the software personally on one or more computers, or installed on a single workstation used non-simultaneously by multiple people, but not both. The registered version of VB CodePro may be accessed through a network, provided that individual licenses have been obtained for the software covering all workstations that will access the software through the network.

A reasonable number of copies of the registered version of the software may be made for backup and archival purposes.

Disclaimer of Warranty

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.  NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.


Ordering

Visual Basic CodePro cannot be purchased until the product is formally released.


Getting Started

It’s easy to get started with CodePro.  The installation program automatically registers and enables the VB add-in.  Once the VB development environment is up and running, simply right-click in a code pane and select CodePro Options.  On the General tab, enter your name in the Author textbox.  Check the “Add Code Markers” box if you want CodePro to insert markers that preceed and follow all code that it adds.  Default code templates for module header, procedure header, error handler header, and error handler footer are automatically loaded.  Different ones can be selected via the Templates tab.

Once the options are set, CodePro can begin to earn its keep:

Adding a Module Header

Adding Procedure Headers

Adding Error Handlers

Adding Headers and Error Handlers to an Entire Project


Adding a Module Header

To add a comment header to a code module:

•	Open the module

•	Right-click in the code pane

•	Select Add Module Header

A module header, based on the template selected in CodePro Options, will be inserted at the beginning of the code module.  If the first line of the code module contains Option Explicit , then the header is inserted at the second line.

BEFORE:

AFTER:

Note that CodePro can remove the code that it adds if the Add Code Markers check box is checked on the Options dialog.

See:

CodePro Options

Removing Code Markers

Removing Code Added by CodePro


Adding Procedure Headers

To add procedure headers to a code module:

•	Open the module

•	To add a header to a single procedure, place the cursor anywhere in the procedure’s text

or

To add a header to multiple procedures, select (highlight) these procedures.  Note that adding headers to all procedures in a module is easy - just type CTRL-A, which selects all text in the module

•	Right-click in the code pane

•	Select Add Header(s) to Selected Procedures

A procedure header, based on the template selected in CodePro Options, will be inserted at the first non-comment line preceeding the procedure.

BEFORE:

AFTER:

Note that CodePro annotated all of the selected procedures with tailored header comments.

CodePro can remove the code that it adds if the Add Code Markers check box is checked on the Options dialog.

See:

CodePro Options

Removing Code Markers

Removing Code Added by CodePro


Adding Error Handlers

In CodePro, error handlers consist of two parts - a header that is inserted after the procedure declaration statement, and a footer that is inserted above the End XYZ statement (where XYZ is Sub, Function, or Property).  Naturally, the header and footer each have their own template that can be tailored to meet your needs.

To add error handlers to procedures:

•	Open the module

•	To add an error handler to a single procedure, place the cursor anywhere in the procedure’s text

or

To add error handlers to multiple procedures, select (highlight) these procedures.  Note that adding headers to all procedures in a module is easy - just type CTRL-A, which selects all text in the module.

•	Right-click in the code pane

•	Select Add Error Handler(s) to Procedures

BEFORE:

AFTER:

Note that CodePro only annotated the procedure where the cursor had been, and that it tailored the error handler’s header and footer to this particular procedure.

CodePro can remove the code that it adds if the Add Code Markers check box is checked on the Options dialog.

See:

CodePro Options

Removing Code Markers

Removing Code Added by CodePro


Removing Code Markers

If the Add Code Markers check box (on the Options dialog) is checked, CodePro will add markers (' [CodePro Begin] and ' [CodePro End]) to delineate the start and end of any code that it adds.  CodePro searches for these makers when removing the code that it has added.

If you are sure that you wish to keep the code added by CodePro, you can remove the code markers by following these steps:

•	Select the text containing the code markers you wish to remove

•	Right-click in the code pane

•	Select Remove CodePro Markers from Selection

Note:  Once the markers have been removed, CodePro will no longer be able to remove the code that it’s added from the affected region.

See also:

Removing Code Markers from Entire Project


Removing Code Added by CodePro

If the Add Code Markers check box (on the Options dialog) is checked, CodePro will add markers (' [CodePro Begin] and ' [CodePro End]) to delineate the start and end of any code that it adds.  All code located within the markers (including any subsequently added by the author) can be removed by following these steps:

•	Select the text containing the code you wish to remove

•	Right-click in the code pane

•	Select Remove Code Added by CodePro from Selection

CodePro will search for matching Begin/End marker pairs and delete all lines in between (as well as the marker lines).

See also:

Removing Code Added by CodePro from Entire Project


Adding Headers and Error Handlers to an Entire Project

With a single click of a mouse, CodePro can add formatted headers to every module in a project, and error handlers and headers to every procedure in every module.  All you have to do is right-click on the project’s icon in the Project Explorer window, then select Add Headers and Error Handlers to Entire Project.


Removing Code Markers from Entire Project

CodePro can remove all code markers added to an entire project.  To do so, simply right-click on the project’s icon in the Project Explorer window, then select Remove All Code Markers from Entire Project.

Note:  Once the markers have been removed, CodePro will no longer be able to remove the code that it’s added from the affected region.

See Removing Code Markers for a discussion of removing code markers from selected text within a module.


Removing Code Added by CodePro from Entire Project

CodePro can remove all code it’s added from an entire project.  To do so, simply right-click on the project’s icon in the Project Explorer window, then select Remove All Code Added by CodePro from Entire Project.

CodePro will search for matching Begin/End marker pairs and delete all lines in between (as well as the marker lines).  Obviously, any code added by the author within the markers will be deleted as well.

See also:

Removing Code Added by CodePro.


Closing All Windows

CodePro can close all Visual Basic code and designer windows that are open.  Select Close All Windows from the Tools menu.


CodePro Options

General Tab

Author:  Name of the author, replaces the %Author% keyword in CodePro templates.

Add Code Markers:  If checked,  code markers (' [CodePro Begin] and ' [CodePro End]) are added to all code added by CodePro.

Templates

Allows the user to select which template file to use for module headers, procedure headers, error handler header, and error handler footer.


Creating Templates

CodePro uses ASCII text templates when inserting code into a module.  Four templates are recognized:

•	Module Header

•	Procedure Header

•	Error Handler Header

•	Error Handler Footer

During installation, CodePro copies a set of default templates into the \CodePro\Templates directory.  The default templates conform to the standard given in Microsoft’s Visual Basic Programmer’s Guide.  In addition, a number of other error handling templates applicable to specific situations (e.g. On Error Resume Next) are installed.

Templates are most powerful, however, when they are tailored to match the coding conventions of a particular company or programmer.  CodePro recognizes the following keywords in any of the templates:

KEYWORD	DESCRIPTION

%Module Name%	Current module’s name
%Procedure Name%	Current procedure’s name
%Procedure Type%	Function, Sub, or Property
%TypedScopedProcedureName%	e.g. Private Function Foo
%Parameters%	Formatted list of a procedure’s parameters
%ParameterNames%	Formatted list of a procedure’s parameters (names only)
%Author%	Author (set via the Options dialog)
%Date%	Today’s date

Consider the procedure header template shown below:

'******************************************************************************

'                    %TypedScopedProcedureName%

'

' PURPOSE:

'

' ASSUMPTIONS:

'

' EFFECTS:

'

' INPUTS: %ParameterNames%

'

' RETURNS:

'

'******************************************************************************

When the programmer adds this header to a private function called Foo which takes the integer Age as an input, the following source code is inserted:

'******************************************************************************

'                    Private Function Foo

' PURPOSE:

'

' ASSUMPTIONS:

'

' EFFECTS:

'

' INPUTS:

'   Age

'

' RETURNS:

'

'******************************************************************************

A note on error handlers:  Although the error handler header and footer are intended to simplify the task of adding error-handling code to an application, they do not have to perform that function.  Ultimately, they just take whatever’s in the header and footer templates and place them just below the procedure declaration line and just above the End Function {or Property, or Sub} statement.  If an application requires the writing a lot of repetitive code, the error handler header and/or footer can be rewritten (once) to accomplish the entire task.


Coding Tips

Tip #1:  Ensure that there are no syntax errors in procedures that will be affected by CodePro operations

In particular, any syntax error that confuses Visual Basic as to the starting or ending point of a procedure will also confuse CodePro, potentially leading to unexpected results.

Tip #2:  Avoid using the colon statement separator on the same line as the End Sub/Property/Function

CodePro places the error handler footer on the line preceeding the End Sub/Property/Function statement.  If the End Sub line contains multiple statements separated by one or more colons, the error handler footer will be inserted before the line.

Here’s an example of what not to do (because the error handler footer would be placed before the i=23 statement:

Public Property Let P9(ByVal vNewValue As Variant)

Dim i As Integer

i = 23: End Property

Better:

Public Property Let P9(ByVal vNewValue As Variant)

Dim i As Integer

i = 23

End Property